/**
 * @class 引力透镜
 * @author DuskyHuang 圣子
 * @deprecated 使用cocos的后处理管线废弃，统一不不适用后处理关系了，用shader实现。
*/

// import { _decorator, gfx, postProcess, Material, renderer, rendering, Color, Vec4, Node } from 'cc';
// const { Format } = gfx;
// const { ForwardPass } = postProcess;
// const { ccclass, property, menu, executeInEditMode } = _decorator;

// @ccclass('cocosmos.gravitational-lens')
// @executeInEditMode(true)
// export class GravitationalLens extends postProcess.PostProcessSetting {

//     @property(Node)
//     public hole: Node = null;

//     @property(Material)
//     private _material: Material | undefined = null;

//     @property(Material)
//     public get material(): Material { return this._material; }
//     public set material(arg: Material) { this._material = arg; }

//     @property(Color)
//     public get holeColor(): Color { return this._holeColor; }
//     public set holeColor(arg: Color) { this._holeColor = arg; }

//     @property(Color)
//     private _holeColor: Color = Color.WHITE.clone();
//     @property
//     private _holes: Vec4 = new Vec4(0, 0, 0, 1);

//     protected update(): void {
//         if (this._material && this._pass0 && this.hole) {
//             const { x, y, z } = this.hole.worldPosition;
//             this._holes.set(x, y, z, this.hole.worldScale.x * 2);
//             // console.log(this._holes.w);
//             this._pass0.setUniform(this._handleHColor, this._holeColor);
//             this._pass0.setUniform(this._handleHoles, this._holes);
//         }
//     }

//     private _pass0: renderer.Pass = null;
//     private _handleHColor: number = 0;
//     private _handleHoles: number = 0;
//     protected onLoad(): void {
//         if (this._material) {
//             this._pass0 = this.material.passes[0];
//             this._handleHColor = this._pass0.getHandle('holeColor');
//             this._handleHoles = this._pass0.getHandle('holes');
//         }
//     }

//     protected start(): void {
//     }
// }

// export class GLensPass extends postProcess.SettingPass {
//     name = 'GLensPass';
//     outputNames = ['GLensPassMap'];

//     get setting() { return this.getSetting(GravitationalLens); }

//     checkEnable(camera: renderer.scene.Camera) {
//         return this.setting && this.setting.material && this.setting.enabled && super.checkEnable(camera);
//     }

//     public render(camera: renderer.scene.Camera, ppl: rendering.Pipeline): void {
//         const cameraID = this.getCameraUniqueID(camera);

//         let context = this.context;
//         this.context.setClearFlag(gfx.ClearFlagBit.NONE);
//         context.clearBlack();

//         let input0 = this.lastPass.slotName(camera, 0);
//         let output = this.slotName(camera);

//         const setting = this.setting;
//         // let forwardPass = builder.getPass(ForwardPass);
//         // let depth = forwardPass.slotName(camera, 1);
//         context.material = setting.material;

//         context
//             .updatePassViewPort()
//             .addRenderPass('post-process', `${this.name}${cameraID}`)
//             .setPassInput(input0, 'inputTexture')
//             // .setPassInput(depth, 'depthTexture')
//             .addRasterView(output, gfx.Format.RGBA8)
//             .blitScreen(0)
//             .version();
//     }
// }

// let builder = rendering.getCustomPipeline('Custom') as postProcess.PostProcessBuilder;
// if (builder) {
//     // builder.insertPass(new GLensPass, postProcess.BlitScreenPass);
// }